/**
 * 创建User实例模型
 */
const Sequelize = require("sequelize");
const sequelize = require("../database/db-sequelize");

const User = sequelize.define("user",
    {
        id: {
            type: Sequelize.INTEGER,
            autoIncrement: true,
            primaryKey: true,
            unique: true
        },
        username: {
            type: Sequelize.STRING(100),//指定值的类型
            unique: true,
            //field: 'user_name' // 指定存储在表中的键名称
        },
        password: Sequelize.STRING(100),
        nickname: Sequelize.STRING(100),
        role: Sequelize.STRING(2),
        status: Sequelize.INTEGER(1)
    },
    {
        freezeTableName: true,
        timestamps: false
    }
)
// timestamps 默认为true，表示数据库会自动更新createAt 和 updateAt 字段
// freezeTableName 默认为true，会自动给表名表示为复数，user->users

// 创建表，默认为false，true则为删除原有表，再创建
User.sync({ force: false })

module.exports = User;